//
//  HomeThreeBtnTableCell.m
//  DanaKreditLoan
//
//  Created by ZhengChengFeng on 2024/10/19.
//

#import "HomeThreeBtnTableCell.h"

@implementation HomeThreeBtnTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        CGFloat fix = (kScreenWidth - 60 - 210)/2;
        
        self.backView1 = [[UIView alloc] init];
        self.backView1.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.backView1];
        [self.backView1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(30);
            make.width.equalTo(@70);
            make.height.equalTo(@48);
            make.top.equalTo(self.contentView.mas_top);
        }];
        self.backView1.layer.cornerRadius = 24;
        self.backView1.layer.masksToBounds = YES;
        
        self.icon1 = [[UIImageView alloc] init];
        [self.backView1 addSubview:self.icon1];
        [self.icon1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.with.height.equalTo(@30);
            make.center.equalTo(self.backView1);
        }];
        
        self.backView1.userInteractionEnabled = YES;
        self.backView1.tag = 1;
        UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickTap:)];
        [self.backView1 addGestureRecognizer:tap1];
        
        self.lab1 = [UILabel createLabel:[UIFont fontWithName:kFutura size:12] color:kBlackColor];
        [self.contentView addSubview:self.lab1];
        self.lab1.textAlignment = 1;
        [self.lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.backView1.mas_centerX);
            make.width.equalTo(@(kScreenWidth/3));
            make.height.equalTo(@15);
            make.top.equalTo(self.backView1.mas_bottom).offset(10);
        }];
        
        
        
        
        self.backView2 = [[UIView alloc] init];
        self.backView2.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.backView2];
        [self.backView2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.backView1.mas_right).offset(fix);
            make.width.equalTo(@70);
            make.height.equalTo(@48);
            make.top.equalTo(self.contentView.mas_top);
        }];
        self.backView2.layer.cornerRadius = 24;
        self.backView2.layer.masksToBounds = YES;
        
        self.icon2 = [[UIImageView alloc] init];
        [self.backView2 addSubview:self.icon2];
        [self.icon2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.with.height.equalTo(@30);
            make.center.equalTo(self.backView2);
        }];
        
        self.backView2.userInteractionEnabled = YES;
        self.backView2.tag = 2;
        UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickTap:)];
        [self.backView2 addGestureRecognizer:tap2];
        
        self.lab2 = [UILabel createLabel:[UIFont fontWithName:kFutura size:12] color:kBlackColor];
        [self.contentView addSubview:self.lab2];
        self.lab2.textAlignment = 1;
        [self.lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.backView2.mas_centerX);
            make.width.equalTo(@(kScreenWidth/3));
            make.height.equalTo(@15);
            make.top.equalTo(self.backView2.mas_bottom).offset(10);
        }];
        
        
        self.backView3 = [[UIView alloc] init];
        self.backView3.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.backView3];
        [self.backView3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.backView2.mas_right).offset(fix);
            make.width.equalTo(@70);
            make.height.equalTo(@48);
            make.top.equalTo(self.contentView.mas_top);
        }];
        self.backView3.layer.cornerRadius = 24;
        self.backView3.layer.masksToBounds = YES;
        
        self.icon3 = [[UIImageView alloc] init];
        [self.backView3 addSubview:self.icon3];
        [self.icon3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.with.height.equalTo(@30);
            make.center.equalTo(self.backView3);
        }];
        
        self.backView3.userInteractionEnabled = YES;
        self.backView3.tag = 3;
        UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickTap:)];
        [self.backView3 addGestureRecognizer:tap3];
        
        self.lab3 = [UILabel createLabel:[UIFont fontWithName:kFutura size:12] color:kBlackColor];
        [self.contentView addSubview:self.lab3];
        self.lab3.textAlignment = 1;
        [self.lab3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.backView3.mas_centerX);
            make.width.equalTo(@(kScreenWidth/3));
            make.height.equalTo(@15);
            make.top.equalTo(self.backView3.mas_bottom).offset(10);
        }];
        

    }
    return self;
}

- (void)clickTap:(UITapGestureRecognizer *)tap{
    UIView *vv = tap.view;
    if (_clickBtnBlock) {
        _clickBtnBlock(vv.tag);
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
